import {legacy_createStore as createStore, applyMiddleware} from 'redux';
import reduxThunk from 'redux-thunk';
import reducers from './reducers'

import {composeWithDevTools} from 'redux-devtools-extension'
//将redux连接浏览器中的localStorage，将用户相关的数据存储到localStorage中
import {persistStore, persistReducer} from "redux-persist";
import storageSession from 'redux-persist/lib/storage/session';

const storageConfig = {
    key: 'root',
    storage: storageSession,
    whitelist: ['user']
}
const storagePersistReducer = persistReducer(storageConfig, reducers);
const store = createStore(storagePersistReducer, composeWithDevTools(applyMiddleware(reduxThunk)));
export const persistor = persistStore(store);

export default store;
